<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <a-form-item label="客群名称">
              <a-input placeholder="" v-model="queryParam.title" allowClear></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="default" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleToDist" type="primary" icon="save">会员发券</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">领取明细</a>
        </span>
        <span slot="execStatus" slot-scope="text, record">
          <a-tag color="green" v-if="text==2">执行成功</a-tag>
          <a-tag color="blue" v-if="text==1">执行中</a-tag>
          <a-tag color="blue" v-if="text==0">待执行</a-tag>
          <a-tag color="red" v-if="text==-1">执行失败<a-tooltip :title="record.execMessage"><a-icon type="question-circle-o"></a-icon></a-tooltip></a-tag>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <PosMarketSenceTaskList ref="modalForm"></PosMarketSenceTaskList>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import PosMarketSenceTaskList from './modules/PosMarketSenceTaskList'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import moment from 'moment'

export default {
  name: 'PosMarketDistCouponSenceList',
  mixins: [JeecgListMixin],
  components: {
    PosMarketSenceTaskList,
  },
  data() {
    return {
      description: '定向发券',
      disableMixinCreated: true,
      isExport: false,
      moment,
      // 表头
      columns: [
        {
          title: '客群名称',
          align: 'center',
          dataIndex: 'title',
        },
        {
          title: '会员数',
          align: 'center',
          dataIndex: 'successMemberCnt',
        },
        {
          title: '发券数',
          align: 'center',
          dataIndex: 'successCouponCnt',
        },
        {
          title: '操作人',
          align: 'center',
          dataIndex: 'creator',
        },
        {
          title: '操作时间',
          align: 'center',
          dataIndex: 'updateTime',
        },
        {
          title: '发券状态',
          align: 'center',
          dataIndex: 'execStatus',
          scopedSlots: { customRender: 'execStatus' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/marketing/sence/posMarketSence/list?senceType=24',
      },
    }
  },
  computed: {},
  created(){
    this.loadData()
  },
  methods: {
    handleToDist(){
      this.$router.push({ path: '/member/list'})
    },
    handleDetail(record) {
     this.$refs.modalForm.view(record) 
     this.$refs.modalForm.visible = true
    }
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>